package com.codeoss.module.res.pagebean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.codeoss.framework.context.YunContext;
import com.codeoss.framework.view.component.Message;
import com.codeoss.framework.view.pagebean.FormViewPageBean;
import com.codeoss.module.res.model.ResUser;
import com.codeoss.module.res.service.IResUserService;

@Service
public class ResUserListViewPageBean extends FormViewPageBean {
	@Autowired
	private PasswordEncoder passwordEncoder;
	@Autowired
	private IResUserService resUserService;
	@Transactional
	public void resetPassword() {
		YunContext yunContext=YunContext.getCurrentContext();
		Long resUserId=(Long)getCurrentKeyValue();
		ResUser resUser=resUserService.getById(resUserId);
		String encodePassword=passwordEncoder.encode("123456");
		resUser.setPassword(encodePassword);
		resUserService.update(resUser);
		yunContext.addMessage(new Message("重置成功"));
	}
}
